package com.isdepci.project.gasEmission.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.gasEmission.domain.Logistics;
import com.isdepci.project.gasEmission.service.ILogisticsService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 物流Controller
 *
 * @author isdepci
 * @date 2023-09-01
 */
@RestController
@RequestMapping("/logistics/logistics")
public class LogisticsController extends BaseController
{
    @Autowired
    private ILogisticsService logisticsService;

    /**
     * 查询物流列表
     */
    @PreAuthorize("@ss.hasPermi('logistics:logistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(Logistics logistics)
    {
        startPage();
        List<Logistics> list = logisticsService.selectLogisticsList(logistics);
        return getDataTable(list);
    }

    /**
     * 导出物流列表
     */
    @PreAuthorize("@ss.hasPermi('logistics:logistics:export')")
    @Log(title = "物流", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Logistics logistics)
    {
        List<Logistics> list = logisticsService.selectLogisticsList(logistics);
        ExcelUtil<Logistics> util = new ExcelUtil<Logistics>(Logistics.class);
        return util.exportExcel(list, "logistics");
    }

    /**
     * 获取物流详细信息
     */
    @PreAuthorize("@ss.hasPermi('logistics:logistics:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(logisticsService.selectLogisticsById(id));
    }

    /**
     * 新增物流
     */
    @PreAuthorize("@ss.hasPermi('logistics:logistics:add')")
    @Log(title = "物流", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Logistics logistics)
    {
        return toAjax(logisticsService.insertLogistics(logistics));
    }

    /**
     * 修改物流
     */
    @PreAuthorize("@ss.hasPermi('logistics:logistics:edit')")
    @Log(title = "物流", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Logistics logistics)
    {
        return toAjax(logisticsService.updateLogistics(logistics));
    }

    /**
     * 删除物流
     */
    @PreAuthorize("@ss.hasPermi('logistics:logistics:remove')")
    @Log(title = "物流", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(logisticsService.deleteLogisticsByIds(ids));
    }
}
